package com.zlx.sharelive.activity;

import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.zlx.module_base.base_ac.BaseAc;
import com.zlx.sharelive.R;
import com.zlx.sharelive.utils.StringUt;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 修改昵称
 */
public class NickNameAc extends BaseAc {

    @BindView(R.id.et_nickname)
    EditText et_nickname;


    private String nickname = "";

    @Override
    protected int getLayoutId() {
        return R.layout.ac_nickname;
    }

    @Override
    public void initViews() {
        super.initViews();

        nickname = getIntent().getStringExtra("nickname");

        et_nickname.setText(nickname);
    }

    @OnClick({R.id.iv_back, R.id.bt_saving, R.id.iv_close})
    public void setOnClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.iv_close:
                et_nickname.setText("");
                break;
            case R.id.bt_saving:
                if (StringUt.isEmpty(et_nickname.getText().toString().trim())) {
                    Toast.makeText(this, "请输入昵称", Toast.LENGTH_SHORT).show();
                } else {
                    Intent intent = new Intent(this, MyInfoAc.class);
                    intent.putExtra("nickname", et_nickname.getText().toString().trim());
                    setResult(30, intent);
                    finish();
                }
                break;
        }
    }
}
